package com.heima.article.controller;


import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.heima.api.dto.ArticleHomeDto;
import com.heima.api.entity.ApArticle;
import com.heima.api.entity.ApArticleConfig;
import com.heima.article.service.IApArticleService;
import com.heima.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 文章信息表，存储已发布的文章 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-08-12
 */
@RestController
@RequestMapping("/api/v1/article")
@RequiredArgsConstructor
public class ApArticleController {
    private final IApArticleService apArticleService;

    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto articleHomeDto) {

        return ResponseResult.okResult(apArticleService.load(articleHomeDto, 0));
    }

    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto articleHomeDto) {
        return ResponseResult.okResult(apArticleService.load(articleHomeDto, 0));
    }

    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto articleHomeDto) {
        return ResponseResult.okResult(apArticleService.load(articleHomeDto, 2));
    }
}
